﻿Imports lbGlobalcom
Public Class fErrores
    Dim daError As lbGlobalcom.dsGlobalTableAdapters.GLO_ERRORTableAdapter

    Private Sub buscaErrores_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buscaErrores.Click
        Try

            If Me.DsGlobal.GLO_ERROR.GetChanges() IsNot Nothing Then
                GLO_ERRORBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    GLO_ERRORBindingNavigatorSaveItem.PerformClick()
                End If
            End If
            daError.Fill(DsGlobal.GLO_ERROR)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub fErrores_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If Me.DsGlobal.GLO_ERROR.GetChanges() IsNot Nothing Then
                GLO_ERRORBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    GLO_ERRORBindingNavigatorSaveItem.PerformClick()
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub fErrores_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            daError = New lbGlobalcom.dsGlobalTableAdapters.GLO_ERRORTableAdapter
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    
    Private Sub GLO_ERRORDataGridView_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles GLO_ERRORDataGridView.DataError
        MessageBox.Show(e.Exception.Message)
    End Sub

    Private Sub GLO_ERRORBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GLO_ERRORBindingNavigatorSaveItem.Click
        Try
            Validate()
            GLO_ERRORBindingSource.EndEdit()
            daError.Update(DsGlobal.GLO_ERROR)
            MessageBox.Show("Se salvarón registros con exito", "Salva Registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub


    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        If MessageBox.Show("Desea borrar el registro", "Elimina registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            GLO_ERRORBindingSource.Remove(GLO_ERRORBindingSource.Current)
            GLO_ERRORBindingNavigatorSaveItem.PerformClick()
        End If
    End Sub

    Private Sub GLO_ERRORDataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles GLO_ERRORDataGridView.UserDeletedRow
        Try
            daError.Update(DsGlobal.GLO_ERROR)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub GLO_ERRORDataGridView_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles GLO_ERRORDataGridView.UserDeletingRow
        Try
            If MessageBox.Show("Esta seguro que desea eliminar este registro", "Elimina Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
                e.Cancel = True
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub
End Class